<?php

class passwordReminderWidgetComponents extends myComponents{

	public function executeRender(){
		sfProjectConfiguration::getActive()->loadHelpers(array('Variable'));
		
		$this->form = new PasswordReminderForm();
		$this->node = $this->getObject();

		// action part
		if($this->hasRequestParameter('passwordRemind')){
			$this->form->bind($this->getRequestParameter($this->form->getName()));
			if($this->form->isValid()){

				// main logic
				$this->getMailer()->composeAndSend(variable('aneto1@gmail.com'), variable('aneto1@gmail.com'), 'Parooli uuendus',
				'Parooli uuendamise p2ring:'."\n".
				implode("\n",$this->form->getValues()) . "\n".
				$this->getRequest()->getUriPrefix() . '/backend.php/users/' . $this->form->getUser()->getId() . '/edit'
				);

				$this->getUser()->setFlash('passwordReminder', 'password reminder sent !');
				$this->getAction()->redirect(LinkGen::getInstance(LinkGen::STRUCTURE)->link($this->getObject()->getId()));	
			}
		}
		
	}

}